import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//1.继承
public class ServletOut extends HttpServlet {

    /**
     *
     */
//	private static final long serialVersionUID = 1L;
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // TODO Auto-generated method stub
        //在控制台上面显示

        System.out.println("doGet方法被调用了");
        //通过response获得界面打印流
        PrintWriter out = resp.getWriter();
        //
        resp.setContentType("text/html;charset=utf-8");
        //输出到界面上
        out.println("<strong>Hello Servlet!&get</strong><br/>");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // TODO Auto-generated method stub
        PrintWriter out = resp.getWriter();
        resp.setContentType("text/html;charset=utf-8");
        out.println("<strong>Hello Servlet!&post</strong>");
    }

}